#include <iostream>
#include <pthread.h>
#include <unistd.h>
#include <typeinfo>

void* routinue(void *args)
{
    std::string name = static_cast<const char *>(args);

    int num = 5;
    while(true)
    {
        std::cout<<"I am new thread name:"<<name<<",tid:"<<pthread_self()<<",num:"<<num<<std::endl;
        sleep(1);
    }

    return 0;
}


int main()
{
    pthread_t tid;
    pthread_create(&tid,nullptr,routinue,(void*)("thread-1"));

    int num = 5;

    while(num--)
    {
        std::cout<<"I am main pthread,tid:"<<pthread_self()<<std::endl;
        sleep(1);

    }
    pthread_cancel(pthread_self());




    return 0;
}